blob: 2c0a3fa6d75e7acb54ef8c36197ccb817853847d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<script lang="ts" context="module">
function fetchJson(url: string): Promise<Response> {
return fetch(url, {
headers: {
"Content-Type": "application/json",
},
});
}
export async function load({ params }) {
// TODO: handle failure cases better
const matchId = params["match_id"];
const matchDataResponse = await fetchJson(`/api/matches/${matchId}`);
if (!matchDataResponse.ok) {
}
const matchLogResponse = await fetchJson(`/api/matches/${matchId}/log`);
if (matchDataResponse.ok && matchLogResponse.ok) {
return {
props: {
matchData: await matchDataResponse.json(),
matchLog: await matchLogResponse.text(),
},
};
}
return {
status: matchDataResponse.status,
error: new Error("failed to load match"),
};
}
</script>
<script lang="ts">
import Visualizer from "$lib/components/Visualizer.svelte";
export let matchLog: string;
export let matchData: object;
</script>
<div class="container">
<Visualizer {matchLog} {matchData} />
</div>
<style lang="scss">
.container {
display: flex;
// these are needed for making the visualizer fill the screen.
min-height: 0;
flex-grow: 1;
overflow: hidden;
}
</style>
|